//跳转注册界面
var newuserbtn=$('.newuserbtn');
newuserbtn.click(function(){
    location.href="registered.html";
})
//验证用户名、密码
/* var msg=document.querySelector(".msg");
var loginbtn=document.querySelector(".loginbtn")
var loginipt=document.querySelectorAll(".main input");
loginbtn.onclick=function(){
    if(!loginipt[0].value&&loginipt[1].value){

    }else{
        //输入框全为null,跳出弹出框
        msg.style.display="block";
    }
    http://jx.xuzhixiang.top/ap/api/login.php?username=11&password=1212
} */
var msg=$(".msg");
var loginbtn=$(".loginbtn");
var loginipt=$(".main>input");
loginbtn.click(function(){
    console.log(loginipt.first().val(),loginipt.last().val());
    if(loginipt.first().val()&&loginipt.last().val()){
        var username=loginipt.first().val();
        var password=loginipt.last().val();
        axios.get(LoginApi,{params:{username,password}}).then(function(res){
            if(res.data.code==1){
                location.href="home.html";
                var arr=[{username:res.data.data.username,uid:res.data.data.id,token:res.data.data.token}];
                localStorage.setItem("user",JSON.stringify(arr));

            }else{
                msg.css("display","block");
                $(".msg>button").click(function(){
                    msg.css("display","none");
                })
                    }
        })
    }else{
        console.log(222);
        msg.css("display","block");
        $(".msg>button").click(function(){
            msg.css("display","none");
        })
    }
})